﻿using System;
using RBOSS.Data;

namespace RBOSS.Business.MyFinance
{
    public class MyFinanceSubsystem : IMyFinanceSubsystem
    {
        readonly MyFinanceDBEntities _dataContext = new MyFinanceDBEntities();
        public IFinance GetFinance()
        {
            return new Finance();
        }

        public bool SaveFinanceInformaiton(IFinance finance)
        {
            try
            {
                var bank = new BankTransaction();
                bank.OrderID = finance.OrderId;
                bank.Percentage = finance.Percentage;
                bank.TotalAmount = finance.TotalAmount;
                bank.VendorBankAccName = finance.VendorBankAccName;
                bank.VendorBankAccNo = finance.VendorBankAccNo;
                bank.VendorBankName = finance.VendorBankName;
                bank.VendorBankNo = finance.VendorBankNo;
                bank.VendorID = finance.VendorId;
                _dataContext.BankTransactions.Add(bank);
                _dataContext.SaveChanges();
               
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
    }
}
